/*******************************************************************************
 * Package: com.hngtrust.iir.company.controller
 * Type:    DictController
 * Date:    2020-11-30 10:59
 *
 * Copyright (c) 2020 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.hngtrust.iir.company.controller;

import com.hngtrust.framework.bind.ResponseInfo;
import com.hngtrust.framework.page.PageResult;
import com.hngtrust.iir.company.controller.vo.AiCompanyReqVO;
import com.hngtrust.iir.company.controller.vo.CompMainBusinessrReqVO;
import com.hngtrust.iir.company.controller.vo.CompMainbusinessRespVO;
import com.hngtrust.iir.company.controller.vo.CompStockRespVO;
import com.hngtrust.iir.company.controller.vo.ListAnnualRespVO;
import com.hngtrust.iir.company.controller.vo.ListBidReqVO;
import com.hngtrust.iir.company.controller.vo.ListBidRespVO;
import com.hngtrust.iir.company.controller.vo.ListCreditRateRespVO;
import com.hngtrust.iir.company.controller.vo.ListCustomerRespVO;
import com.hngtrust.iir.company.controller.vo.ListHolderReqVO;
import com.hngtrust.iir.company.controller.vo.ListQualificationRespVO;
import com.hngtrust.iir.company.controller.vo.ListSupplierRespVO;
import com.hngtrust.iir.company.controller.vo.ListTaxRespVO;
import com.hngtrust.iir.company.service.ManageService;
import com.hngtrust.iir.dto.ReqDTO;
import com.hngtrust.iir.exception.IirErrorType;
import com.hngtrust.iir.exception.IirException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 公司经营信息
 * @author Chentianyong
 * @date 2021-03-22 10:59
 */
@Slf4j
@Api(tags = "公司经营信息")
@RestController
@RequestMapping("/company")
public class ManageController {
    
    @Autowired
    private ManageService manageService;
    
    
    /**
     * 公司股票信息
     */
    @ApiOperation(value = "公司股票信息", notes = "公司股票信息")
    @PostMapping("/info-stock")
    public ResponseInfo<CompStockRespVO> infoStock(
            @ApiParam(value = "公司股票信息") @Valid @RequestBody ListHolderReqVO req) {
        log.info("ManageController.infoStock start...");
    
        if(!(req.getCompId() > 0L)){
            throw new IirException(IirErrorType.INTFACE_PARAMS_ERROR,"ID");
        }
    
        CompStockRespVO resp = manageService.infoStock(req);
        
        ResponseInfo<CompStockRespVO> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }
    
    /**
     * 公司主营业务
     */
    @ApiOperation(value = "公司主营业务", notes = "公司主营业务")
    @PostMapping("/comp-mainbusiness")
    public ResponseInfo<CompMainbusinessRespVO> compMainbusiness(
            @ApiParam(value = "公司主营业务") @Valid @RequestBody CompMainBusinessrReqVO req) {
        log.info("CompanyController.compMainbusiness start...");
    
        CompMainbusinessRespVO resp = manageService.compMainbusiness(req);
        
        ResponseInfo<CompMainbusinessRespVO> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }

    /**
     * 公司供应商列表
     */
    @ApiOperation(value = "公司供应商列表", notes = "公司供应商列表")
    @PostMapping("/list-supplier")
    public ResponseInfo<PageResult<ListSupplierRespVO>> listSupplier(
            @ApiParam(value = "公司供应商列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("ManageController.listSupplier start...");
    
        PageResult<ListSupplierRespVO> pageResult = manageService.listSupplier(req);

        return new ResponseInfo(pageResult);
    }

    /**
     * 公司客户列表
     */
    @ApiOperation(value = "公司客户列表", notes = "公司客户列表")
    @PostMapping("/list-customer")
    public ResponseInfo<PageResult<ListCustomerRespVO>> listCustomer(
            @ApiParam(value = "公司客户列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("ManageController.listCustomer start...");
    
        PageResult<ListCustomerRespVO> pageResult = manageService.listCustomer(req);

        return new ResponseInfo(pageResult);
    }

    /**
     * 公司招投标类型列表profit-struct
     */
    @ApiOperation(value = "公司招投标类型列表", notes = "公司招投标类型列表")
    @PostMapping("/list-bid-type")
    public ResponseInfo<List<AiCompanyReqVO>> listBidType() {
        log.info("ManageController.listBidType start...");
    
        List<AiCompanyReqVO> resp = manageService.listBidType();

        ResponseInfo<List<AiCompanyReqVO>> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }

    /**
     * 公司招投标列表
     */
    @ApiOperation(value = "公司招投标列表", notes = "公司招投标列表")
    @PostMapping("/list-bid")
    public ResponseInfo<PageResult<ListBidRespVO>> listBid(
            @ApiParam(value = "公司招投标列表") @Valid @RequestBody ReqDTO<ListBidReqVO> req) {
        log.info("ManageController.listBid start...");
    
        PageResult<ListBidRespVO> pageResult = manageService.listBid(req);
        
        return new ResponseInfo(pageResult);
    }

    /**
     * 公司税务信用列表
     */
    @ApiOperation(value = "公司税务信用列表", notes = "公司税务信用列表")
    @PostMapping("/list-tax")
    public ResponseInfo<PageResult<ListTaxRespVO>> listTax(
            @ApiParam(value = "公司税务信用列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("ManageController.listTax start...");
    
        PageResult<ListTaxRespVO> pageResult = manageService.listTax(req);

        return new ResponseInfo(pageResult);
    }

    /**
     * 公司信用评级列表
     */
    @ApiOperation(value = "公司信用评级列表", notes = "公司信用评级列表")
    @PostMapping("/list-creditrate")
    public ResponseInfo<PageResult<ListCreditRateRespVO>> listCreditRate(
            @ApiParam(value = "公司信用评级列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("ManageController.listCreditRate start...");
    
        PageResult<ListCreditRateRespVO> pageResult = manageService.listCreditRate(req);
        
        return new ResponseInfo(pageResult);
    }

    /**
     * 公司年报列表
     */
    @ApiOperation(value = "公司年报列表", notes = "公司年报列表")
    @PostMapping("/list-annual")
    public ResponseInfo<PageResult<ListAnnualRespVO>> listAnnual(
            @ApiParam(value = "公司年报列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("ManageController.listAnnual start...");
    
        PageResult<ListAnnualRespVO> pageResult = manageService.listAnnual(req);

        return new ResponseInfo(pageResult);
    }

    /**
     * 公司资质列表
     */
    @ApiOperation(value = "公司资质列表", notes = "公司资质列表")
    @PostMapping("/list-qualification")
    public ResponseInfo<PageResult<ListQualificationRespVO>> listQualification(
            @ApiParam(value = "公司资质列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("ManageController.listQualification start...");
    
        PageResult<ListQualificationRespVO> pageResult = manageService.listQualification(req);
        
        return new ResponseInfo(pageResult);
    }
}
